package org.project.programeditor.model.programming;

import org.boxlayout.gui.type.ColorEnum;
import org.boxlayout.widget.Widget;
import org.boxlayout.widget.base.ActionLabel;
import org.boxlayout.widget.base.EditableLabel;
import org.boxlayout.widget.base.Label;
import org.boxlayout.widget.base.Spacer;
import org.boxlayout.widget.container.Container;
import org.boxlayout.widget.container.Container.ContainerLayout;
import org.boxlayout.widget.event.ActionEvent;
import org.boxlayout.widget.event.ActionListener;
import org.boxlayout.widget.menu.Menu;

public class Method {
	Widget border;
	Widget container;
	Widget head;
	Widget body;
	Widget foot;
	
	Container menu;
	
	EditableLabel methodName;
	
	public Method() {
		
		container = new Container().setLayout(ContainerLayout.VERTICAL);
		//container.setColor(ColorEnum.GRAY);
		
		methodName = new EditableLabel();
		methodName.getVisual().setPaddingLeft(.1f).setPaddingRight(.1f);
		

		menu = menu();
		
		head = new Container().append(menu).append(methodName).append(new Label("(){"));
		body = new Container().setLayout(ContainerLayout.VERTICAL);		
		foot = new Container().append(new Label("}"));
		
		container.append(head).append(new Spacer(0.1f)).append(body).append(new Spacer(0.1f)).append(foot);
		
		border = new Container();
		border.getVisual().setColor(ColorEnum.WHITE).setPadding(0.1f);
		border.append(container);
		
	}
	
	Container menu() {
		Menu menu = new Menu("Method");

		menu.append(new ActionLabel("[AddLine]").setOnClick(new ActionListener() {
			
			@Override
			public void action(Widget target,ActionEvent actionEvent) {
				
			}
		}));

		

		return menu;
	}

	
	

	public Widget getWidget() {
		return border;
	}

	public Method setName(String string) {
		methodName.setText(string);
		return this;
	}
}
